package com.shxc.smarttrade.utils.sp;

import android.content.Context;

import org.xchris.cache.SpCache;

import static com.shxc.smarttrade.utils.sp.SpPublic.ACCSTATUS;
import static com.shxc.smarttrade.utils.sp.SpPublic.ACCTYPE;
import static com.shxc.smarttrade.utils.sp.SpPublic.BIRTHDAY;
import static com.shxc.smarttrade.utils.sp.SpPublic.DEALSWITCH;
import static com.shxc.smarttrade.utils.sp.SpPublic.EMAIL;
import static com.shxc.smarttrade.utils.sp.SpPublic.FASTCLOSE;
import static com.shxc.smarttrade.utils.sp.SpPublic.FASTOPEN;
import static com.shxc.smarttrade.utils.sp.SpPublic.FIRSTLOGIN;
import static com.shxc.smarttrade.utils.sp.SpPublic.HEADURL;
import static com.shxc.smarttrade.utils.sp.SpPublic.INTRODUCTION;
import static com.shxc.smarttrade.utils.sp.SpPublic.INVITECODE;
import static com.shxc.smarttrade.utils.sp.SpPublic.ISFIRSTOPEN;
import static com.shxc.smarttrade.utils.sp.SpPublic.ISFORCE;
import static com.shxc.smarttrade.utils.sp.SpPublic.ISLOGIN;
import static com.shxc.smarttrade.utils.sp.SpPublic.NEWVERSION;
import static com.shxc.smarttrade.utils.sp.SpPublic.NICK;
import static com.shxc.smarttrade.utils.sp.SpPublic.RONGIMTOKEN;
import static com.shxc.smarttrade.utils.sp.SpPublic.SEX;
import static com.shxc.smarttrade.utils.sp.SpPublic.TODAY;
import static com.shxc.smarttrade.utils.sp.SpPublic.UPDATEMSG;
import static com.shxc.smarttrade.utils.sp.SpPublic.UPDATEURL;
import static com.shxc.smarttrade.utils.sp.SpPublic.USERID;
import static com.shxc.smarttrade.utils.sp.SpPublic.USERKEY;

/**
 * 首选项工具类 - 加密保存
 */
public class SpImp {

    private SpCache sp;

    public void clear() {
        sp.clear();
    }

    public SpImp(Context context) {
        sp = new SpCache(context);
    }

    public long getUserId() {
        return sp.get(USERID, -1);
    }

    public void setUserId(int userId) {
        sp.put(USERID, userId);
    }

    public boolean isFirstOpen() {
        return sp.get(ISFIRSTOPEN, true);
    }

    public void setFirstOpen(boolean firstOpen) {
        sp.put(ISFIRSTOPEN, firstOpen);
    }


    public String getEmail() {
        return sp.get(EMAIL, "");
    }

    public void setEmail(String email) {
        sp.put(EMAIL, email);
    }

    public String getRongimtoken() {
        return sp.get(RONGIMTOKEN, "");
    }

    public void setRongimtoken(String rongimtoken) {
        sp.put(RONGIMTOKEN, rongimtoken);
    }

    public String getUserKey() {
        return sp.get(USERKEY, "");
    }

    public void setUserKey(String userKey) {
        sp.put(USERKEY, userKey);
    }

    public boolean isLogin() {
        return sp.get(ISLOGIN, false);
    }

    public void setLogin(boolean islogin) {
        sp.put(ISLOGIN, islogin);
    }

    public boolean isFirstLogin() {
        return sp.get(FIRSTLOGIN, false);
    }

    public void setFirstLogin(boolean firstLogin) {
        sp.put(FIRSTLOGIN, firstLogin);
    }

    public String getNick() {
        return sp.get(NICK, "");
    }

    public void setNick(String nick) {
        sp.put(NICK, nick);
    }

    public String getBirthday() {
        return sp.get(BIRTHDAY, "");
    }

    public void setBirthday(String birthday) {
        sp.put(BIRTHDAY, birthday);
    }

    public long getSex() {
        return sp.get(SEX, 0);
    }

    public void setSex(long sex) {
        sp.put(SEX,sex);
    }

    public String getHeadUrl() {
        return sp.get(HEADURL, "");
    }

    public void setHeadUrl(String headUrl) {
        sp.put(HEADURL,headUrl);
    }

    public String getIntroduction() {
        return sp.get(INTRODUCTION, "");
    }

    public void setIntroduction(String introduction) {
        sp.put(INTRODUCTION,introduction);
    }

    public String getNewversion() {
        return sp.get(NEWVERSION, "");
    }

    public void setNewversion(String newversion) {
        sp.put(NEWVERSION,newversion);
    }

    public String getUpdatemsg() {
        return sp.get(UPDATEMSG, "");
    }

    public void setUpdatemsg(String updatemsg) {
        sp.put(UPDATEMSG,updatemsg);
    }

    public String getUpdateurl() {
        return sp.get(UPDATEURL, "");
    }

    public void setUpdateurl(String updateurl) {
        sp.put(UPDATEURL,updateurl);
    }

    public boolean isForce() {
        return sp.get(ISFORCE, false);
    }

    public void setForce(boolean force) {
        sp.put(ISFORCE,force);
    }

    public String getToday() {
        return sp.get(TODAY, "");
    }

    public void setToday(String today) {
        sp.put(TODAY,today);
    }

    public boolean isDealSwitch() {
        return sp.get(DEALSWITCH, false);
    }

    public void setDealSwitch(boolean dealSwitch) {
        sp.put(DEALSWITCH,dealSwitch);
    }

    public long getAccType() {
        return sp.get(ACCTYPE,0);
    }

    public void setAccType(int accType) {
        sp.put(ACCTYPE,accType);
    }


    public long getAccStatus() {
        return sp.get(ACCSTATUS,-1);
    }

    public void setAccStatus(long accStatus) {
        sp.put(ACCSTATUS,accStatus);
    }

    public boolean isFastOpen() {
        return sp.get(FASTOPEN,false);
    }

    public void setFastOpen(boolean fastOpen) {
        sp.put(FASTOPEN,fastOpen);
    }

    public boolean isFastClose() {
        return sp.get(FASTCLOSE,false);
    }

    public void setFastClose(boolean fastClose) {
        sp.put(FASTCLOSE,fastClose);
    }

    public String getInviteCode() {
        return sp.get(INVITECODE,"");
    }

    public void setInviteCode(String inviteCode) {
        sp.put(INVITECODE,inviteCode);
    }
}
